package com.xgc.book.bookserver.controller;


import com.xgc.book.bookserver.bean.*;
import com.xgc.book.bookserver.service.*;
import com.xgc.book.bookserver.util.ResultJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 会员信息表 前端控制器
 * </p>
 *
 * @author wrz
 * @since 2023-11-20
 */
@RestController
@RequestMapping("/vip")
public class VipController {
    @Autowired
    private VipService vipService;
    @Autowired
    private BookLikeService bookLikeService;
    @Autowired
    private BookCommentService bookCommentService;
    @Autowired
    private RecordService recordService;
    @Autowired
    private FeedbackService feedbackService;

    @GetMapping("/page")
    public ResultJson page(int page, int limit, VipBean vipBean) {
        return vipService.getPage(page, limit, vipBean);
    }

    @GetMapping("/info/{vipId}")
    public ResultJson info(@PathVariable int vipId) {
        return ResultJson.ok(vipService.getById(vipId));
    }

    @PostMapping("/status")
    public ResultJson update(@RequestBody VipBean vipBean) {
        vipService.updateById(vipBean);
        return ResultJson.ok();
    }

    @DeleteMapping("/delete/{vipId}")
    public ResultJson delete(@PathVariable int vipId) {
        vipService.deleteVip(vipId);
        return ResultJson.ok();
    }

    @GetMapping("/like/page")
    public ResultJson likePage(int page, int limit, BookLikeBean bookLike) {
        return bookLikeService.getPage(page, limit, bookLike);
    }

    @GetMapping("/comment/page")
    public ResultJson commentPage(int page, int limit, BookCommentBean bookComment) {
        return bookCommentService.getPage(page, limit, bookComment);
    }

    @GetMapping("/record/page")
    public ResultJson recordPage(int page, int limit, RecordBean record) {
        return recordService.getPage(page, limit, record);
    }

    @GetMapping("/feedback/page")
    public ResultJson feedbackPage(int page, int limit, FeedbackBean feedback) {
        return feedbackService.getPage(page, limit, feedback);
    }
}

